package reno.ribbon.ribbon.alerts;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import reno.ribbon.ribbon.common.JSONUtils;

@Service
public class AlertsService {

    @Autowired
    RestTemplate restTemplate;

//    @HystrixCommand(fallbackMethod = "getAlertsInfoError")
    public JSONObject getAlertsInfo() {
        return restTemplate.getForObject("http://alerts/getAlertsInfo", JSONObject.class);
    }

    public JSONObject getAlertsInfoError() {
        return JSONUtils.failure("Sorry,Service invocation failed.");
    }

}
